﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>EditOnline</title>
    <script language="javascript" type="text/javascript">
        function show_word() {
            var id = encodeURI('<%: ViewData["strwordpath"] %>');
            document.all.MyOffice.Open(id, true, "Word.Document");
            document.all.MyOffice.SetTrackRevisions(0);
        }

        function show_excel() {
            document.all.MyOffice.CreateNew("Excel.Sheet"); //新建空白文档
            document.all.MyOffice.Titlebar = true; //隐藏/显示标题栏~
            document.all.MyOffice.Caption = "Excel文档"; //设置标题栏文字
        }

        function show_power() {
            document.all.MyOffice.CreateNew("PowerPoint.Show"); //新建空白文档
            document.all.MyOffice.Titlebar = true; //隐藏/显示标题栏~
            document.all.MyOffice.Caption = "PowerPoint文档"; //设置标题栏文字
        }

        function show_excelchart() {
            document.all.MyOffice.CreateNew("Excel.Chart"); //新建空白文档
            document.all.MyOffice.Titlebar = true; //隐藏/显示标题栏~
            document.all.MyOffice.Caption = "Excel图表文档"; //设置标题栏文字
        }

        function save() {
            document.all.MyOffice.HttpInit();
            document.all.MyOffice.HttpAddPostCurrFile("File", "");
            var src = "http://localhost:1557/Shared/SaveImage"; //到时候要改端口号
            returnValue = document.all.MyOffice.HttpPost(src); //执行上传动作
            if (returnValue == "true") {
                alert("保存成功");
            } else {
                alert("保存失败");
            }
        }
    </script>
</head>
<body>
    <div>
        <center>
            <input id="Submit1" type="button" value="Word" onclick="show_word()" />  
            <input id="btnexcel" type="button" value="Excel" onclick="show_excel()" />  
            <input id="btnexcelchart" type="button" value="Excel图表" onclick="show_excelchart()" />  
            <input id="btnpower" type="button" value="PowerPoint" onclick="show_power()" />   
        </center>

        <object id="MyOffice" name = "MyOffice" style="LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 500px;"
        classid="clsid:00460182-9E5E-11D5-B7C8-B8269041DD57" codebase="dsoframer.ocx#version=2,2,0,0" >
        </object><br /><br />
    
        <center>
            <input id="btnsave" type="submit" value=" 保 存 " onclick="return save()" />   
            提示：存入根目录下的images文件夹里
        </center>
    </div>
</body>
</html>
